home *** CD-ROM | disk | FTP | other *** search
- Path: freenet2.freenet.ufl.edu!afn03257
- From: afn03257@freenet2.freenet.ufl.edu (Daniel P Hudson)
- Newsgroups: comp.lang.c,comp.lang.c++,alt.msdos.programmer
- Subject: Re: Clearing the keyboard buffer
- Date: 22 Jan 1996 14:45:37 GMT
- Message-ID: <4e07uh$oqq@huron.eel.ufl.edu>
- References: <4dtqi4$60u@cdc2.cdc.net>
- NNTP-Posting-Host: freenet2.afn.org
- X-Newsreader: wsOMR/SOUP v1.00 [NR]
-
- In article <4dtqi4$60u@cdc2.cdc.net>,
- mart@vianet.on.ca (Mart) wrote:
-
- > I'm using Turbo C++ v. 3.1 and I need to be able to clear the keyboard
- > BTW, this following bit of code wouldn't work :
-
- > while(kbhit()) getch();
-
- > Because I want the user to be able to just keep pushing the same key,
- > making the above loop infinitly. If I don't clear the keyboard buffer,
- > my code will continue believing that the user is pushing a key, even
- > though their not.
-
- Huh? Once the buffer is caught up, it shouldn't continue, but you
- might want to try fflush(stdin); just the same. The code you had
- should work as soon as it has read through all the keystrokes currently
- stored, the only way it should have a situation like you describe is if
- the user presses a key after it has executed, in which case your only
- prevention would be to disable the keyboard.
-
-